<template>
  <div id="Recruitment">
    <vxe-table border stripe :data="recruitmentData">
      <vxe-table-column title="职位" field="position" align="center"></vxe-table-column>
      <vxe-table-column title="工作地点" field="location" align="center"></vxe-table-column>
      <vxe-table-column title="联系电话" field="phone" align="center"></vxe-table-column>
      <vxe-table-column title="发布时间" field="createTime" align="center" :formatter="formatDate"></vxe-table-column>
      <vxe-table-column title="操作" align="center">
        <template v-slot="{row}">
          <el-button type="danger" size="mini" @click="deleteRecruitment(row)">删除</el-button>
        </template>
      </vxe-table-column>
    </vxe-table>
  </div>
</template>

<script>
import {deleteRecruitment, listRecruitment} from "@/api/recruitment";
import dayjs from "dayjs";

export default {
  name: "Recruitment",
  data() {
    return {
      recruitmentData: []
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      listRecruitment().then(res => {
        this.recruitmentData = res.data.list
      })
    },
    deleteRecruitment(row) {
      deleteRecruitment({id: row.id}).then(res => {
        if (res.resultCode === 200) {
          this.$message.success('操作成功')
          this.getData()
        }
      })
    },
    formatDate(row) {
      return dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss')
    }
  }
}
</script>

<style scoped lang="scss">
#Recruitment {
}
</style>
